const origin = 'http://59.36.87.106:9080';
module.exports = {
  publicPath: '/ams',
  devServer: {
    port: 5000, //项目本地运行端口号
    proxy: {
      // '/api': {
      //     target: origin + '/iot_service',
      //     ws: true,
      //     changeOrigin: true,
      //     pathRewrite: {
      //         '^/api': '/'
      //     }
      // },
      '/code': {
        target: origin + '/iot_user',
        ws: true,
        logLevel: 'debug',
        changeOrigin: true
      },
      '/service': {
        target: origin + '/iot_service',
        ws: true,
        logLevel: 'debug',
        changeOrigin: true
      },
      '/user': {
        target: origin + '/iot_user',
        ws: true,
        changeOrigin: true
      }
    }
  },
  productionSourceMap: false,
  chainWebpack: config => {
    // 移除 prefetch 插件
    config.plugins.delete('prefetch');
  },
  configureWebpack: config => {
    if (process.env.NODE_ENV === 'production') {
      // 清空console
      config.optimization.minimizer[0].options.terserOptions.compress.warnings = false;
      config.optimization.minimizer[0].options.terserOptions.compress.drop_console = true;
      config.optimization.minimizer[0].options.terserOptions.compress.drop_debugger = true;
      config.optimization.minimizer[0].options.terserOptions.compress.pure_funcs = ['console.log'];
    }
  }
};
